<!--管理员登录页面-->
<template>

  <div class="bg">
    <img src="../assets/images/bg.jpg" alt="">
    <div class="login-center">
      <div class="login-l">
        <img src="../assets/images/login-img.png" alt="">
      </div>

      <div class="login-r" v-if="!qrShow">
        <h3>防疫酒店管控系统</h3>
        <p>Welcome欢迎登录</p>

        <div class="inp">
          <p style="margin: 0;">账号：</p>
          <input v-model="resetForm.username" type="text" placeholder="请输入用户名">
        </div>
        <div class="inp">
          <p style="margin: 0;">密码：</p>
          <input v-model="resetForm.password" type="password" placeholder="请输入密码">
        </div>

        <button @click="login()">登录</button>
        <button @click="QRCode(true)" style="margin-top: 20px">二维码登录</button>

      </div>
      <div class="login-r" v-if="qrShow">
        <h3>酒店管理系统</h3>
        <p>Welcome欢迎登录</p>
        <div class="qr">
          <p style="font-size: 16px;color: #666666" v-if="confirmShow">
            <i style="color: #67C23A" class="el-icon-success"></i>&nbsp已扫描成功,请在手机上按确认登录
          </p>
          <vue-qr :logo-src="logoSrc"
                  :size="180"
                  :margin="0"
                  :auto-color="true"
                  :dot-scale="1"
                  :text="code"
                  v-if="!confirmShow"
          />
        </div>
        <button @click="QRCode(false)" style="margin-top: 6px">账号密码登录</button>

      </div>
    </div>
  </div>

</template>

<script>
export default {
  data() {
    return {
      logoSrc: '',
      qrShow: false,
      confirmShow: false,
      ruleForm: {
        username: '',
        password: ''
      },
      rules: {
        username: [
          {required: true, message: '请输入账号', trigger: 'blur'},
          {min: 4, max: 15, message: '长度在 4 到 15 个字符', trigger: 'blur'}
        ],
        password: [
          {required: true, message: '请输入密码', trigger: 'blur'},
          {min: 6, max: 12, message: '长度在 6 到 12 个字符', trigger: 'blur'}
        ]
      }
    };
  },
  methods: {
    // 登录
    login(){

    },
    open() {
      this.imgvisible = true;
    },
    submitForm(formName) {
      // 检查表单是否通过验证
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },

  }
}

</script>

<style scoped>
* {
  padding: 0;
  margin: 0;
}

.bg {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bg img {
  width: 100%;
  height: 100%;
  opacity: 0.6;
  position: absolute;
}

.login-center {
  width: 700px;
  height: 300px;
  background-color: #fff;
  box-shadow: 0px 0px 40px -10px #000;
  border-radius: 20px;
  padding: 60px 50px;
  display: flex;
  z-index: 9;
  justify-content: space-between;
}

.login-l img {
  width: 300px;
  height: 300px;
  opacity: 1;
}

.login-l, .login-r {
  width: 100%;
}

.login-r h3 {
  font-size: 25px;
  font-weight: normal;
  margin-top: 10px;
}

.login-r p {
  margin-top: 10px;
  margin-bottom: 20px;
  color: #ccc;
}

.inp {
  display: flex;
  align-items: center;
  height: 50px;
  border-bottom: 1px solid #ccc;
}

.inp input {
  width: 300px;
  height: 30px;
  outline: none;
  border: none;
  color: #ccc;
  font-size: 16px;
}

.login-r button {
  width: 300px;
  height: 35px;
  background-color: #4f93fe;
  color: #fff;
  border-radius: 50px;
  border: none;
  margin-top: 50px;
  cursor: pointer;
}

.qr {
  width: 100%;
  height: 200px;

}

.qr img {
  width: 180px;
  height: 180px;
  margin: 0 auto;
  opacity: 0.7;

}
</style>


